﻿using System;
using System.Text;
using VipCo.Data;
using VipCo.Entities;

public partial class Controls_FacebookPageControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HienthiLinkTinTuc();
        }
    }
    public void HienthiLinkTinTuc()
    {
        // Lay ID tin Khuyen mai
        int totalRows = 0;
        string whereClause = "TenNhom like N'" + Common.NhomTinTuc_KhuyenMai + "' and TrangThai = 1";

        TList<NhomTinTuc> tlistNhomTinTucs = DataRepository.NhomTinTucProvider.GetPaged(whereClause, "Id DESC", 0, 0,
            out totalRows);

        if (tlistNhomTinTucs.Count > 0)
        {
            string dieuKien = "IdNhomTin = " + tlistNhomTinTucs[0].Id + " and TrangThai = 1";

            TList<TinTuc> tlistTinTucs = DataRepository.TinTucProvider.GetPaged(dieuKien, "NgayCapNhat DESC", 0, 5, out totalRows);
            StringBuilder sbHotnews = new StringBuilder();

            foreach (var tintuc in tlistTinTucs)
            {
                sbHotnews.Append("<a href=\" " + "" + tintuc.Id + "_" + GetTieuDe(tintuc.TieuDe) + "_baiviet.aspx" + "\">");
                sbHotnews.Append("" + tintuc.TieuDe + "");
                sbHotnews.Append("</a>");
            }

            litHotNews.Text = sbHotnews.ToString();
        }
    }
    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }
}